package de.au.fi.controller;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import de.au.fi.calc.CalcHelper;
import de.au.fi.imp.ImportStockWorker;
import de.au.fi.imp.Importer;
import de.au.fi.manager.StockManager;

@Component
@Scope("session")
public class ImportController {
	Logger logger = LoggerFactory.getLogger(this.getClass());

	String wkns;
	
	ImportStockWorker importStockWorker;

	@Autowired
	StockManager stockManager;
	
	@Autowired
	SearchResultController searchResultController;
	
	@Autowired
	Importer importer;
	
	public void importTicker(String ticker)
	{
		importStockWorker = new ImportStockWorker(stockManager, searchResultController, importer, ticker);
		importStockWorker.start();
	}
	
	public void importStocks()
	{
		List<String> wknList = CalcHelper.getWknsFromString(wkns);
		importStockWorker = new ImportStockWorker(stockManager, searchResultController, importer, wknList);
		importStockWorker.start();
	}

	public String getWkns() {
		return wkns;
	}

	public void setWkns(String wkns) {
		this.wkns = wkns;
	}

	public ImportStockWorker getImportStockWorker() {
		return importStockWorker;
	}

}
